package net.stratusprogramming.school.Game.Framework.Battle;

import java.util.ArrayList;

import net.stratusprogramming.school.Game.Framework.Items.Spell;
import net.stratusprogramming.school.Game.Framework.Items.Usable;
import net.stratusprogramming.school.Game.Framework.Items.Weapon;
import net.stratusprogramming.school.Game.Framework.Scene.Actor;
import net.stratusprogramming.school.Game.Framework.System.SaveMgr;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;

public abstract class Combatant extends Actor {

	/** Holds the combatant's (physical) weapons */
	protected ArrayList<Weapon> weapons;	
	/** Holds the combatant's magic spells */
	protected ArrayList<Spell> spells;	
	/** Holds the combatant's usable items (potions, etc) */
	protected ArrayList<Usable> items;
	
	/** The combatant's name */
	protected String name = "TestPlayer";	
	/** The combatant's health */
	protected float health = 100.0f;
	/** The combatant's mana */
	protected float mana = 100.0f;
	/** The combatant's maximum health value */
	protected float maxHealth = 100.0f;
	/** The combatant's minimum mana value */
	protected float maxMana = 100.0f;
	
	/** Image of player to draw on the screen */
	protected Image playerImage;
	
	/** Percent of damage the combatant can rebuff */
	protected float defense;
	
	/**
	 * Creates a new Combatant
	 */
	public Combatant()	{
		weapons = new ArrayList<Weapon>();
		spells = new ArrayList<Spell>();
		items = new ArrayList<Usable>();
	}
	
	/**
	 * Handles the action of the player
	 */
	public abstract void act();
	
	
	@Override
	public void update(int delta) {
	}

	@Override
	public void render(Graphics g) {
		if(playerImage != null) {
			g.drawImage(playerImage, x, y);
		}
	}

	@Override
	public void save(SaveMgr saveMgr) {
	}

	@Override
	public void load(SaveMgr saveMgr) {
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the health
	 */
	public float getHealth() {
		return health;
	}
	/**
	 * @param health the health to set
	 */
	public void setHealth(float health) {
		if(health < 0)
			this.health = 0;
		else if(health > maxHealth)
			this.health = maxHealth;
		else
			this.health = health;
	}
	/**
	 * @return the mana
	 */
	public float getMana() {
		return mana;
	}
	/**
	 * @param mana the mana to set
	 */
	public void setMana(float mana) {
		if(mana < 0)
			this.mana = 0;
		else if(mana > maxMana)
			this.mana = maxMana;
		else
			this.mana = mana;
	}
	/**
	 * @return the defense
	 */
	public float getDefense() {
		return defense;
	}
	/**
	 * @param defense the defense to set
	 */
	public void setDefense(float defense) {
		this.defense = defense;
	}
	/**
	 * @return the weapons
	 */
	public ArrayList<Weapon> getWeapons() {
		return weapons;
	}
	/**
	 * @return the spells
	 */
	public ArrayList<Spell> getSpells() {
		return spells;
	}
	/**
	 * @return the items
	 */
	public ArrayList<Usable> getItems() {
		return items;
	}
}
